# 计算1+2！+...+10! 的结果

def test_func(num):
    if num == 0:
        return 1
    return test_func(num - 1) * num


# 函数作为参数
def in_func(number, func1):
    target = 0
    while number >= 0:
        target += func1(number)
        number -= 1

    return target


# number = test_func(3)
# print(number)

total = in_func(10, test_func)
print(total)


def new_func(number):
    """使用嵌套函数来改写这两个函数的写法，也可以改变函数的作用域"""

    def fact_func(num):
        if num == 0:
            return 1
        return fact_func(num - 1) * num

    total = 0
    while number >= 0:
        total += fact_func(number)
        number -= 1

    return total


sum, temp = 0, 1
for i in range(1, 11):
    temp *= i
    sum += temp

print(sum)
